<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>a页面</title>
</head>

<body style="border:1px solid black">
    a页面
    <iframe src="http://localhost:4000/c.html" id="frame" frameborder=" 0" onload="load()" style="border:1px solid red"></iframe>
    <script>
        let onoff = true
        function load() {
            let iframe = document.getElementById("frame")
            if (onoff) {
                iframe.src = "http://localhost:3000/b.html"
                onoff = false
            } else {
                alert(iframe.contentWindow.name)
            }
        }
    </script>
</body>

</html>